package com.xinchengxd.commons.entity.order;

import com.xinchengxd.commons.entity.goods.Goods;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author: 姚新成
 * @Date: 2021/11/9:15:08
 * @Description:
 */

@Data
@RequiredArgsConstructor
@NoArgsConstructor
public class OrderItem implements Serializable {
    private Integer id;
    private Order order;
    @NonNull
    private Goods goods;
    @NonNull
    private Integer nums;
    @NonNull
    private BigDecimal price;

    private BigDecimal money;


    public void CreateMoney(){
        if(nums==null || price==null){
            money = new BigDecimal("0");
        }
        String s = String.valueOf(nums);
        BigDecimal nums = new BigDecimal(s);
        money =  price.multiply(nums);

    }
}
